<template>
  <a-modal v-model="visible" title="导入位置编号" :maskClosable="false" centered @ok="submit">
    <a-form-model ref="form" :model="form" :rules="rules" :label-col="{ span: 24 }" :wrapper-col="{ span: 24 }">
      <a-form-model-item label="导入方式" prop="rule">
        <a-radio-group :options="ruleOptions" v-model="form.rule" />
      </a-form-model-item>
      <a-form-model-item label="请输入位置编号" prop="importSeatCodeStr">
        <a-textarea v-model="form.importSeatCodeStr" placeholder="请输入位置编号,用英文逗号隔开" :rows="5" />
      </a-form-model-item>
      <div>注: 不同的编号,用英文逗号隔开,例如: A1001,A1002,A1003</div>
    </a-form-model>
  </a-modal>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      form: {},
      rules: {
        rule: [{ required: true, message: '请选择导入方式', trigger: 'change' }],
        importSeatCodeStr: [{ required: true, message: '请输入位置编号', trigger: 'blur' }]
      },
      ruleOptions: [
        { label: '覆盖导入', value: 'COVER' },
        { label: '延续导入', value: 'APPEND' },
      ]
    }
  },
  methods: {
    openModel(groupId) {
      this.form = {
        groupId,
        rule: this.form.rule || "COVER",
        importSeatCodeStr: ''
      }
      this.visible = true
    },
    closeModel() {
      this.visible = false
    },
    submit() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.$emit('submit', this.form)
        }
      })
    }
  }
}
</script>

<style></style>
